package ${serviceImplPackage};

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ${entityPackage}.${domainObjectName}Key;
import ${entityPackage}.${domainObjectName}Example;
import ${mappingPackage}.${domainObjectName}Mapper;
import ${pagingInfo}.PagingInfo;
import ${servicePackage}.${domainObjectName}Service;
import com.github.pagehelper.PageHelper;

/**
 * 生成关系表的实现
 * @author fengz
 *
 */
@Service
public class ${domainObjectName}ServiceImpl implements ${domainObjectName}Service {
    @Autowired
    ${domainObjectName}Mapper ${lowerDomainObjectName}Mapper;

    @Override
    public List<${domainObjectName}Key> list() {
        return ${lowerDomainObjectName}Mapper.selectByExample(new ${domainObjectName}Example());
    }
    
    @Override
    public List<${domainObjectName}Key> pagingList(PagingInfo pagingInfo) {
    	
        PageHelper.startPage(pagingInfo.getPageNum(),pagingInfo.getPageSize());
        
        ${domainObjectName}Example ${lowerDomainObjectName}Example = new ${domainObjectName}Example();
        pagingInfo.buildExample(${lowerDomainObjectName}Example,${domainObjectName}Key.class);
        List<${domainObjectName}Key> ${lowerDomainObjectName}List = ${lowerDomainObjectName}Mapper.selectByExample(${lowerDomainObjectName}Example);
        return ${lowerDomainObjectName}List;
    }

	@Override
	public void save(${domainObjectName}Key ${lowerDomainObjectName}) {
	    ${lowerDomainObjectName}Mapper.insertSelective(${lowerDomainObjectName});
	}

	@Override
	public void delete(List<${domainObjectName}Key> ids) {
	    for (${domainObjectName}Key ${lowerDomainObjectName}Key : ids) {
	        ${lowerDomainObjectName}Mapper.deleteByPrimaryKey(${lowerDomainObjectName}Key);
        }
	}
	
	@Override
    public void delete(PagingInfo pagingInfo) {
	    ${domainObjectName}Example ${lowerDomainObjectName}Example = new ${domainObjectName}Example();
        pagingInfo.buildExample(${lowerDomainObjectName}Example,${domainObjectName}Key.class);
        ${lowerDomainObjectName}Mapper.deleteByExample(${lowerDomainObjectName}Example);
    }
    
}
